<template>
  <div>
    <!-- 面包屑导航条 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>系统中心</el-breadcrumb-item>
      <el-breadcrumb-item>联系人管理</el-breadcrumb-item>
      <el-breadcrumb-item>编辑联系人</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card class="box-card">
      <el-form :model="linkForm" label-width="70px" ref="linkForm" :rules="rules">
        <el-row :gutter="14">
          <el-col :span="7">
            <el-form-item label="姓名" prop="name">
              <el-input v-model="linkForm.name"  size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="电话" prop="tel">
              <el-input v-model="linkForm.tel"  size="small"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="14">
          <el-col :span="7">
            <el-form-item label="邮箱" prop="email">
              <el-input v-model="linkForm.email"  size="small"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="性别" prop="sex">
              <el-radio :label="0" v-model="linkForm.sex">男</el-radio>
              <el-radio :label="1" v-model="linkForm.sex">女</el-radio>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="7">
            <el-form-item label="收件地址" prop="recvAddress">
              <el-input v-model="linkForm.recvAddress"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="职位" prop="position">
              <el-input v-model="linkForm.position"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="14">
          <el-col :span="14">
            <el-form-item label="描述">
              <el-input
                type="textarea"
                placeholder="请输入内容"
                v-model="linkForm.remarks"
                maxlength="50"
                show-word-limit></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>

      <el-button @click="resetForm('linkForm')">重置</el-button>
      <el-button @click="saveMan()" type="primary">保存</el-button>

    </el-card>
  </div>
</template>

<script>
    export default {
        name: "upLinkMan",
      data(){
        return{
          linkForm:{
            name:null,
            tel:null,
            email:null,
            recvAddress:null,
            position:null,
            sex:null,
            remarks:null,
          },
          rules: {
            name: [
              { required: true, message: '姓名', trigger: 'blur' }
            ],
            tel: [
              { required: true, message: '请输入电话', trigger: 'blur' }
            ],
            email: [
              { required: true, message: '请输入邮箱', trigger: 'blur' }
            ],
            recvAddress: [
              { required: true, message: '请输入收件地址', trigger: 'blur' }
            ],
            position: [
              { required: true, message: '请输入职位', trigger: 'blur' }
            ],
            sex: [
              { required: true, message: '请选择性别', trigger: 'change' }
            ],
          }
        }

      },methods:{
        saveMan:function () {
          this.$http.post("/linkMan/addMan",this.linkForm).then((res)=>{
            if (res.data.success) {
              this.$message({
                message: res.data.message,
                type: 'success'
              });
            } else {
              this.$message.error(res.data.message);
            }
            this.$router.push("/linkman")
          })
        },
        resetForm(formName) {
          this.$refs[formName].resetFields();
        },
        searchMan:function(id){

          this.$http.post("/linkMan/getMan/"+id).then((res) => {
            this.linkForm = res.data.result;
          });
        }
      },
      mounted() {
        var id=this.$route.query.id;
        alert(id);
        this.searchMan(id)

      }
    }
</script>

<style scoped>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
</style>
